package com.gcxy.controller;


import com.gcxy.core.PageVO;
import com.gcxy.core.R;
import com.gcxy.dto.export.DownloadFileDTO;
import com.gcxy.dto.export.ExportRecordPageDTO;
import com.gcxy.entity.ExportRecord;
import com.gcxy.service.ExportRecordService;
import com.gcxy.vo.record.ExportRecordVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import javax.servlet.http.HttpServletResponse;

/**
 * <p>
 * 导出周报记录表 前端控制器
 * </p>
 *
 * @author Huang先森
 * @since 2024-07-22
 */
@RestController
@RequestMapping("/exportRecord")
@Api(value = "ExportRecordController", tags = "导出记录管理")
public class ExportRecordController {


    @Autowired
    private ExportRecordService exportRecordService;

    @PostMapping(value = "/createFile")
    @ApiOperation(value = "生成文件")
    public R<?> createFile(@RequestBody @Validated DownloadFileDTO dto) {
        return exportRecordService.createFile(dto);
    }

    @ApiOperation(value = "下载文件")
    @GetMapping(value = "/download")
    public R<?> download(@RequestParam("id") Integer id, HttpServletResponse response) {
        return exportRecordService.download(id, response);
    }

    @ApiOperation(value = "分页查询导出记录")
    @PostMapping("/getExportRecordByPage")
    public R<PageVO<ExportRecordVO>> getExportRecordByPage(@RequestBody ExportRecordPageDTO exportRecordPageDto) {
        return exportRecordService.getExportRecordByPage(exportRecordPageDto);
    }
}

